#include "optionswidget.h"
#include "filetable.h"
#include "slepui.h"


void OptionsWidget::createMethodFlags(){
    QLayout *layout = new QVBoxLayout(this);
    QWidget *methodFlagsWidget = new QWidget(this);
    methodFlagsWidget->setLayout(layout);
    tabWidget->addTab(methodFlagsWidget,tr("Method"));
    methodFlags = new QGroupBox(tr("Method Flags"), this);

    QGridLayout *methodFlagsLayout = new QGridLayout;

    buttonGroupMFlag = new QButtonGroup(this);
    labelMFlag = new QLabel(tr("Method used : "));
    buttonGroupMFlag->addButton(new QRadioButton(tr("Accelerated Method (uses Objective Function as compositive function)")),0);
    buttonGroupMFlag->addButton(new QRadioButton(tr("Reformulated Smooth Objective Function Method")),1);
    buttonGroupMFlag->setExclusive(true);
    (buttonGroupMFlag->button(0))->setChecked(true);

    methodFlagsLayout->addWidget(labelMFlag,0,0,2,1,Qt::AlignLeft | Qt::AlignTop);
    methodFlagsLayout->addWidget(buttonGroupMFlag->button(0),0,1,Qt::AlignLeft);
    methodFlagsLayout->addWidget(buttonGroupMFlag->button(1),1,1,Qt::AlignLeft);

    buttonGroupLFlag = new QButtonGroup(this);
    labelLFlag = new QLabel(tr("Line Search : "));
    buttonGroupLFlag->addButton(new QRadioButton(tr("Nemirovski's Line Search")),0);

    buttonGroupLFlag->addButton(new QRadioButton(tr("Adaptive Line Search")),1);
    buttonGroupLFlag->setExclusive(true);
    (buttonGroupLFlag->button(0))->setChecked(true);

    methodFlagsLayout->addWidget(labelLFlag,2,0,2,1,Qt::AlignLeft | Qt::AlignTop);
    methodFlagsLayout->addWidget(buttonGroupLFlag->button(0),2,1,Qt::AlignLeft);
    methodFlagsLayout->addWidget(buttonGroupLFlag->button(1),3,1,Qt::AlignLeft);
    (buttonGroupLFlag->button(1))->setEnabled(false);

    methodFlags->setLayout(methodFlagsLayout);

    connect(buttonGroupMFlag->button(0),SIGNAL(clicked()),buttonGroupLFlag->button(0),SLOT(click()));
    connect(buttonGroupMFlag->button(0),SIGNAL(clicked(bool)),buttonGroupLFlag->button(1),SLOT(setDisabled(bool)));
    connect(buttonGroupMFlag->button(1),SIGNAL(clicked(bool)),buttonGroupLFlag->button(1),SLOT(setEnabled(bool)));

    opts->mFlag = 0;
    opts->lFlag = 0;

    layout->addWidget(methodFlags);
    ((QBoxLayout*)layout)->addStretch();
}